package com.dacd.soundanalysis.soundhelper

/**
 * 获取声音大小
 */
class VolumeUtil {

    companion object {
        /**
         * 获取声音的分贝
         */
        fun getVolume(bufferRead: Array<Byte>, length: Int): Double {
            var volume = 0.0
            for (i in 0 until bufferRead.size) {
                volume += bufferRead[i] * bufferRead[i]
            }
            return volume / length.toDouble()
        }
    }
}